﻿


using System.Windows.Controls;
using System.Windows;

namespace WpfApp2;

public partial class ProfilePage : Page
{
   
    
    
    
    
    // 模拟用户信息
    private string username = "admin";
    private string email = "admin@example.com";

    public ProfilePage()
    {
        InitializeComponent();
        LoadUserProfile();
    }

    // 加载用户信息到显示面板
    private void LoadUserProfile()
    {
        UsernameText.Text = username;
        EmailText.Text = email;
    }

    // 点击“编辑资料”
    private void EditProfile_Click(object sender, RoutedEventArgs e)
    {
        // 填充编辑表单
        UsernameBox.Text = username;
        EmailBox.Text = email;

        // 显示编辑面板，隐藏显示面板
        DisplayPanel.Visibility = Visibility.Collapsed;
        EditPanel.Visibility = Visibility.Visible;
    }

    // 点击“保存”
    private void SaveProfile_Click(object sender, RoutedEventArgs e)
    {
        // 更新信息
        username = UsernameBox.Text;
        email = EmailBox.Text;

        // 更新显示
        LoadUserProfile();

        // 切换回显示面板
        EditPanel.Visibility = Visibility.Collapsed;
        DisplayPanel.Visibility = Visibility.Visible;

        MessageBox.Show("资料已保存", "成功", MessageBoxButton.OK, MessageBoxImage.Information);
    }

    // 点击“取消”
    private void CancelEdit_Click(object sender, RoutedEventArgs e)
    {
        // 不保存，直接切换回显示面板
        EditPanel.Visibility = Visibility.Collapsed;
        DisplayPanel.Visibility = Visibility.Visible;
    }

    
    
    
    
    
}